package com.yeyks.app.controller.base.other;

import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.commonReference.append.app.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author fuchangshuai
 * @date 2019/3/26 3:12 PM
 */
@Api(tags = "上传接口", description = "上传")
@Slf4j
@RestController
@RequestMapping(value = "/upload")
public class UploadController {

    @Autowired
    private OssService ossService;


    /**
     * 用户上传头像
     *
     * @return
     */
    @ApiOperation(value = "用户上传头像", notes = "用户上传头像")
    @PostMapping(value = "/pic")
    public AjaxResponseBody uploadPic(@ApiParam(value = "上传的文件", name = "file", required = true) @RequestParam(name = "file") MultipartFile file) {
        return AjaxResponseBody.success(ossService.ossUpload(null, file));
    }
}
